package com.pay.game.central.web.controller;

import com.pay.game.central.common.Result;
import com.pay.game.central.common.ResultGenerator;
import com.pay.game.central.security.annotaion.UserLoginToken;
import com.pay.game.central.utils.DateTimeUtil;
import com.pay.game.central.web.service.StatisticService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 统计信息
 */
@Controller
@RequestMapping("/statistic")
public class StatisticController {

    @Autowired
    private StatisticService statisticService;

    @GetMapping("/orderAndPayCount")
    @UserLoginToken
    @ResponseBody
    Result<Map<String,Integer>> getUserOrderStatistic(String userId){
        Map<String, Integer> map = new HashMap<>();
        map.put("orderCount", statisticService.countTodayOrderByUserId(userId, DateTimeUtil.getFormatCurrentDate()));
        map.put("payCount", statisticService.countTodayPayByUserId(userId, DateTimeUtil.getFormatCurrentDate()));
        return ResultGenerator.genSuccessResult(map);
    }


}
